package com.jwds.digital.bios.business.core.infrastructure.dto.belt.assembler;

import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltHealthScoreDayReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltHealthScoreDayRespVO;
import com.jwds.digital.bios.business.core.infrastructure.entity.belt.BeltHealthScoreDay;
import java.util.Objects;

/**
 * BeltHealthScoreDay DTO与Entity之间的相互转换
 *
 * @author 林柏云
 * @date 2024-10-24
 */
public class BeltHealthScoreDayAssembler {

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @return 实体对象
  */
  public static BeltHealthScoreDay dto2entity(BeltHealthScoreDayReqDTO dto)  {
    if (dto == null) {
      return null;
    }
    BeltHealthScoreDay entity = new BeltHealthScoreDay();
    entity.setBeltId(dto.getBeltId());
    entity.setScore(dto.getScore());
    entity.setHealthType(dto.getHealthType());
    entity.setScoreDay(dto.getScoreDay());
    return entity;
  }

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @param entity 原实体对象
  * @return 实体对象
  */
  public static BeltHealthScoreDay dto2entity(BeltHealthScoreDayReqDTO dto, BeltHealthScoreDay entity){
    if (dto == null) {
      return null;
    }
    if(Objects.nonNull(dto.getBeltId())) {
      entity.setBeltId(dto.getBeltId());
    }
    if(Objects.nonNull(dto.getScore())) {
      entity.setScore(dto.getScore());
    }
    if(Objects.nonNull(dto.getHealthType())) {
      entity.setHealthType(dto.getHealthType());
    }
    if(Objects.nonNull(dto.getScoreDay())) {
      entity.setScoreDay(dto.getScoreDay());
    }
    return entity;
  }

  /**
  * 将实体对象转换为传输对象
  *
  * @param entity 实体对象
  * @return 传输对象
  */
  public static BeltHealthScoreDayRespVO entity2dto(BeltHealthScoreDay entity) {
    if (entity == null) {
      return null;
    }
    BeltHealthScoreDayRespVO dto = new BeltHealthScoreDayRespVO();
    dto.setId(entity.getId());
    dto.setBeltId(entity.getBeltId());
    dto.setScore(entity.getScore());
    dto.setHealthType(entity.getHealthType());
    dto.setScoreDay(entity.getScoreDay());
    dto.setCreateTime(entity.getCreateTime());
    dto.setModifyTime(entity.getModifyTime());
    dto.setCreateUser(entity.getCreateUser());
    dto.setModifyUser(entity.getModifyUser());
    return dto;
  }

}
